﻿using CPPEI.Coolzon.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace CPPEI.Coolzon.Designer.Views
{
    public class AddPartOperation : OperationBase
    {
        private DesignView _designView;
        private Part _part;
        private IPartContainer _partContainer;
        private Point _point;
        private Size _size;
        private string _shortType;
        public AddPartOperation(DesignView designView, Part part, IPartContainer partContainer, Point point, Size size, string shortType)
        {
            _designView = designView;
            _part = part;
            _partContainer = partContainer;
            _point = point;
            _size = size;
            _shortType = shortType;
        }
        protected override void OnDo()
        {
            _designView.API_AddPart(_part, _partContainer, _point, _size, _shortType);
            if(_part is AreaPart)
            {
                Event.UI.UIEventBus.Publish(new Event.UI.UIChangePartZIndex(_part.XFullName, (_part.ParentPart as IPartContainer).GetPartIndex(_part)));
            }
        }

        protected override void OnUndo()
        {
            _designView.API_Remove(_part);
        }
    }
}
